package org.repchain;

import com.rcjava.protos.Peer;

import java.util.UUID;

/**
 * @author lhc
 * @version 1.0
 * @className ElectricMapper
 * @date 2021年07月07日 5:17 下午
 * @description 描述
 */
public class ElectricClientUtil {


    /**
     * @author lhc
     * @description // 构建合同操作
     * @date 3:16 下午 2021/7/9
     * @params [data, functionName]
     * @return com.rcjava.protos.Peer.Transaction
     **/
    public static Peer.Transaction buildContract(String data, String functionName, SysCert sysCert) {
        String tranId = UUID.randomUUID().toString().replace("-", "");
        ElectricBaseClient userClient = ElectricBaseClient.getClient(sysCert.getCreditCode(), sysCert.getCertName(), sysCert.getPrivateKey(), ElectricBaseClient.ELECTRIC);
        return userClient
                .getTranCreator()
                .createInvokeTran(tranId, userClient.getCertId(), userClient.getElectricId(), functionName, data);
    }


}
